<template>
	<view class="consume">
		<view class="consume-item" v-for="(item,index) in creditList" :key="index">
			<view class="consume-left">
				<view class="num">{{item.remark}}</view>
				<view class="time">{{item.create_at}}</view>
			</view>
			<view class="money">{{item.num}}</view>
		</view>
		<!-- <view class="consume-item">
			<view class="consume-left">
				<view class="num">退款订单：SH20200622123456</view>
				<view class="time">2020-06-22 14:02:26</view>
			</view>
			<view class="money">+365.00</view>
		</view>
		<view class="consume-item">
			<view class="consume-left">
				<view class="num">消费订单：SH20200622123456</view>
				<view class="time">2020-06-22 14:02:26</view>
			</view>
			<view class="money">-365.00</view>
		</view>
		<view class="consume-item">
			<view class="consume-left">
				<view class="num">退款订单：SH20200622123456</view>
				<view class="time">2020-06-22 14:02:26</view>
			</view>
			<view class="money">+365.00</view>
		</view> -->
		
		<view class="consume-img" v-if="creditList.length==0">
			<image class="img" src="../../static/img/record.png" mode=""></image>
			<view class="text">
				暂无记录
			</view>
		</view>
		
	</view>
</template>

<script>
	import service from '@/store/service.js';
	export default {
		data() {
			return {
				creditList: [],
				isLoading: false,
				scroll: false,
				status: 0,
				pages: 1,
				limit: 2,
				page: 0,
				out: 0
			};
		},
		onLoad: function() {
			this.getMyCredit();
		},
			onReachBottom() {
				this.getMyCredit();
			},
		methods: {
			jump(url, id) {
				uni.navigateTo({
					url: url
				});
			},
			getMyCredit() {
				var self = this;
				if (self.isLoading) {
					return;
				}
				if (self.page < self.pages) {
					self.out = 0;
					self.isLoading = true;
					self.scroll = false;
					self.status = 1;
					var page = self.page + 1;
					self.$http
						.post(service.api.balance.myCredit, {
							page: page,
							// num: self.limit
							type:1,
							paytype:1
						})
						.then(function(res) {
							console.log(res);
							if (res.code == 1) {
								var list = res.data.data;
								if(list.length > 0){
									list.forEach(item=>{
										//console.log(item)
										self.creditList.push(item);
									})
									self.pages = page + 1
								}else{
									self.pages = page;
									// self.mobileList.length=list.length
									// console.log(self.mobileList.length);
								}
								
								self.page = page;
								self.scroll = true;
								self.isLoading = false;
								self.out = 1;
							}
						});
					}
			},
		}
	};
</script>

<style scoped>
	.consume-item{
		background-color: #fff;
		margin-top: 20upx;
		display: flex;
		justify-content: space-between;
		padding:28upx 22upx  22upx;
	}
	.num{
		font-weight:bold;
	}
	.time{
		color: #999;
		font-size:24upx;
		font-weight:500;
	}
	.money{
		display: flex;
		align-items: center;
		color: #f81149;
	}
	.consume-img{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 296upx;
	}
	.img{
		width: 522upx;
		height: 350upx;
	}
	.text{
		color: #333;
		font-weight: bold;
	}
</style>
